#!/usr/bin/nodejs

var http=require('http');
var puerto=process.argv[2]?process.argv[2]:8080;

http.createServer(function (req, res) {  
    var split_url=req.url.split("/");
    if ( split_url[1] == '' ) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('Portada');
    } else if ( split_url[1] == 'proc' ) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('No deberias estar aqui');
    } else {
   res.writeHead(418, {'Content-Type': 'text/plain'});
        res.end('Error!!! pagina desconoscid');
    }
}).listen(puerto, '127.0.0.1');
console.log('Server running at http://127.0.0.1:'+puerto+'/');


